home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume11 / swarm / part01
Encoding:
Internet Message Format  |  1990-12-11  |  20.7 KB

  1. Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v11i070:  swarm - display a swarm of lines (PC version), Part01/01
  5. Message-ID: <6583@tekred.CNA.TEK.COM>
  6. Date: 19 Nov 90 21:20:21 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 704
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: "Werner P. Keilholz" <keilholz@rrze2.rrze.uni-erlangen.de>
  12. Posting-number: Volume 11, Issue 70
  13. Archive-name: swarm/Part01
  14. Environment: MS-DOS, Turbo C
  15.  
  16.     [This is a PC port of a X-windows game of the same (or similar)
  17.      name. The author comments that it is written in Turbo C++,
  18.      but it doesn't use any C++'isms and by commenting out a
  19.      few lines should be compilable with Turbo C.  -br]
  20.  
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of archive 1 (of 1)."
  28. # Contents:  README swarm.c swarm.h
  29. # Wrapped by billr@saab on Mon Nov 19 13:13:39 1990
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'README' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'README'\"
  33. else
  34. echo shar: Extracting \"'README'\" \(1010 characters\)
  35. sed "s/^X//" >'README' <<'END_OF_FILE'
  36. X Swarm
  37. X =====
  38. X
  39. X Purpose:     Display a swarm of lines.
  40. X
  41. X Features:    uses only integer math
  42. X              has no redeeming social value
  43. X
  44. X Comments:    This code is derived from a program by Jeff Butterworth,
  45. X              written for the UNIX XWINDOW system.
  46. X              Like it's  predecessor, this PC version (written in
  47. X              TURBO C[++]) has still "no redeeming social value"
  48. X              and is really good for nothing except, maybe, practicing
  49. X              C (in my case). But it looks nice and maybe someone
  50. X              turnes it into some kind of game or something ...
  51. X              I didn't spent too much time with this, so there might
  52. X              still be some 'leftovers' from the UNIX version and,
  53. X              of course, bugs.
  54. X
  55. X              Any comments, enhances, or fixes are welcome!
  56. X
  57. X Created:     by Jeff Butterworth on 7/11/90
  58. X
  59. X Updated:     by Jeff Butterworth on 8/1/90
  60. X PC-Version:  by Werner Keilholz on 10/19/90
  61. X                 (KEILHOLZ@CNVE.RRZE.UNI-ERLANGEN.DE)
  62. END_OF_FILE
  63. if test 1010 -ne `wc -c <'README'`; then
  64.     echo shar: \"'README'\" unpacked with wrong size!
  65. fi
  66. # end of 'README'
  67. fi
  68. if test -f 'swarm.c' -a "${1}" != "-c" ; then 
  69.   echo shar: Will not clobber existing file \"'swarm.c'\"
  70. else
  71. echo shar: Extracting \"'swarm.c'\" \(14177 characters\)
  72. sed "s/^X//" >'swarm.c' <<'END_OF_FILE'
  73. X/*
  74. X** Swarm
  75. X** =====
  76. X**
  77. X** Purpose:     Display a swarm of lines.
  78. X**
  79. X** Features:    uses only integer math
  80. X**              has no redeeming social value
  81. X**
  82. X** Comments:    This code is derived from a program by Jeff Butterworth,
  83. X**              written for the UNIX XWINDOW system.
  84. X**              Like it's  predecessor, this PC version (written in
  85. X**              TURBO C[++]) has still "no redeeming social value"
  86. X**              and is really good for nothing except, maybe, practicing
  87. X**              C (in my case). But it looks nice and maybe someone
  88. X**              turnes it into some kind of game or something ...
  89. X**              I didn't spent too much time with this, so there might
  90. X**              still be some 'leftovers' from the UNIX version and,
  91. X**              of course, bugs.
  92. X**
  93. X**              Any comments, enhances, or fixes are welcome!
  94. X**
  95. X** Created:     by Jeff Butterworth on 7/11/90
  96. X**
  97. X** Updated:     by Jeff Butterworth on 8/1/90
  98. X** PC-Version:  by Werner Keilholz on 10/19/90
  99. X**                 (KEILHOLZ@CNVE.RRZE.UNI-ERLANGEN.DE)
  100. X*/
  101. X
  102. X/* Standard Includes */
  103. X#include <stdio.h>
  104. X#include <stdlib.h>
  105. X
  106. X/* Graphics Includes (TURBO C++) */
  107. X#include <graphics.h>
  108. X
  109. X/* Includes for this project. */
  110. X#include <swarm.h>
  111. X
  112. X/* This is needed for the kbhit function in TURBO C++ */
  113. X#include <conio.h>
  114. X
  115. X
  116. X/* Main()
  117. X** process command line parameters, setup X stuff
  118. X*/
  119. X
  120. Xmain(argc, argv)
  121. Xint argc;
  122. Xchar *argv[];
  123. X
  124. X{
  125. X    /* variables used by the graphic */
  126. X    int errorcode;
  127. X    int graphdriver = DETECT;
  128. X    int graphmode;
  129. X
  130. X
  131. X    /* These variables are used to analyze the command line parameters. */
  132. X    char        option[80];
  133. X    extern int  optind;
  134. X    extern char *optarg;
  135. X    int i;
  136. X
  137. X    /*
  138. X    printf("\n%d Arguments:\n\n",argc);
  139. X    for (i=0; i<= argc; i++)
  140. X    printf("Argument Nr. %d: = %s\n",i,argv[i]);
  141. X    */
  142. X
  143. X    /* Check the command line. */
  144. X
  145. X    i=1;
  146. X
  147. X    while (i < argc)
  148. X    {
  149. X        strcpy(option,argv[i]);
  150. X
  151. X        i++;
  152. X
  153. X        switch (option[0])
  154. X        {
  155. X            case 'v':
  156. X                verbose = TRUE;
  157. X                break;
  158. X            case 'r':
  159. X                break;
  160. X            case 'x':
  161. X                xor = TRUE;
  162. X                break;
  163. X            case 'g':
  164. X                break;
  165. X            case 'b':
  166. X                sscanf(option+1,"%d",&bees);
  167. X                break;
  168. X            case 'a':
  169. X                sscanf(option+1,"%d",&bee_acc);
  170. X                break;
  171. X            case 's':
  172. X                sscanf(option+1,"%d",&bee_vel);
  173. X                break;
  174. X            case 'A':
  175. X                sscanf(option+1,"%d",&wasp_acc);
  176. X                break;
  177. X            case 'S':
  178. X                sscanf(option+1,"%d",&wasp_vel);
  179. X                break;
  180. X            case 'd':
  181. X                {
  182. X                sscanf(option+1,"%d",&delay);
  183. X                }
  184. X                break;
  185. X            case 'B':
  186. X                sscanf(option+1,"%d",&border);
  187. X                break;
  188. X            case 'w':
  189. X                sscanf(option+1,"%d",&wasp_color);
  190. X                break;
  191. X            case 'c':
  192. X                sscanf(option+1,"%d",&bee_color);
  193. X                break;
  194. X            case 'C':
  195. X                sscanf(option+1,"%d",&bg_color);
  196. X                break;
  197. X            case 'h':
  198. X            case 'q':
  199. X            case '?':
  200. X                Usage(*argv);
  201. X                break;
  202. X            default:
  203. X            {
  204. X                printf("\nOption %s unknown !\n", argv[i-1]);
  205. X
  206. X                HandleError("The command line parameters were incorrect.",
  207. X                    FATAL);
  208. X                break;
  209. X            }
  210. X        }
  211. X    }
  212. X
  213. X    /* Display the arguments. */
  214. X    if (verbose)
  215. X    {
  216. X        printf("\nHere are the current settings...\n");
  217. X        if (xor)
  218. X            printf("Trails are not erased.\n");
  219. X        else
  220. X            printf("Trails are erased.\n");
  221. X        printf("There are %d bees.\n", bees);
  222. X        printf("Bee acceleration is %d pixels per frame.\n",bee_acc);
  223. X        printf("Bee speed limit is %d pixels per frame.\n", bee_vel);
  224. X        printf("Wasp acceleration is %d pixels per frame per frame.\n",
  225. X            wasp_acc);
  226. X        printf("Wasp speed limit is %d pixels per frame.\n", wasp_vel);
  227. X        printf("The delay is %d millikeilholz.\n",
  228. X            delay);
  229. X        printf("The wasp can't go within %d pixels of the window edge.\n",
  230. X            border);
  231. X        if (!(wasp_color==0))
  232. X          printf("The wasp color is \"%d\"\n", wasp_color);
  233. X        else
  234. X          printf("The wasp color is (default)\n");
  235. X        if (!(bee_color==0))
  236. X          printf("The bee color is \"%d\"\n", bee_color);
  237. X        else
  238. X          printf("The bee color is (default)\n");
  239. X        if (!(bg_color==0))
  240. X          printf("The background color is \"%d\"\n", bg_color);
  241. X        else
  242. X          printf("The background color is (default)\n", bg_color);
  243. X
  244. X        printf("\nHit a key to continue ...\n");
  245. X        getch();
  246. X
  247. X    }
  248. X
  249. X
  250. X    winW = winH = winX = winY = 0;
  251. X
  252. X    /* Open the display. */
  253. X    initgraph(&graphdriver, &graphmode,"\\tc\\bgi");
  254. X    errorcode = graphresult();
  255. X
  256. X    if (errorcode != grOk)
  257. X    {
  258. X        HandleError("Cannot open display.\n");
  259. X        exit(-1);
  260. X    }
  261. X
  262. X    /* Set the colors. */
  263. X    if (!(bg_color == 0)) setbkcolor(bg_color);
  264. X
  265. X    /* Set up window parameters, create and map window if necessary */
  266. X        winW = getmaxx();
  267. X        winH = getmaxy();
  268. X        winX = 0;
  269. X        winY = 0;
  270. X
  271. X
  272. X    /* Animate the swarm. */
  273. X    Animate();
  274. X
  275. X    closegraph();
  276. X
  277. X    printf("\n SWARM by Jeff Butterworth and Werner Keilholz\n");
  278. X    printf("\n type SWARM h  for options");
  279. X
  280. Xreturn(0);
  281. X}
  282. X
  283. X
  284. X
  285. Xint Animate()
  286. X{
  287. X    register int        b;              /* bee index */
  288. X    XSegment            *segs;          /* bee lines */
  289. X    XSegment            *old_segs;      /* old bee lines */
  290. X    short               *x, *y;         /* bee positions x[time][bee#] */
  291. X    short               *xv, *yv;       /* bee velocities xv[bee#] */
  292. X    short               wx[3], wy[3];
  293. X    short               wxv, wyv;
  294. X/*    XEvent            xev;  */
  295. X    short               dx,dy,distance;
  296. X    int                 init = TRUE;
  297. X    int FGcolor;
  298. X    int BGcolor;
  299. X
  300. X
  301. X    /* Get the random number generator ready.
  302. X    srandom((int) time(0) % 231); */
  303. X
  304. X    /* Allocate memory. */
  305. X    segs = (XSegment *) malloc(sizeof(XSegment) * bees);
  306. X    old_segs = (XSegment *) malloc(sizeof(XSegment) * bees);
  307. X    x = (short *) malloc(sizeof(short) * bees * times);
  308. X    y = (short *) malloc(sizeof(short) * bees * times);
  309. X    xv = (short *) malloc(sizeof(short) * bees);
  310. X    yv = (short *) malloc(sizeof(short) * bees);
  311. X
  312. X    /* Initialize point positions, velocities, etc. */
  313. X
  314. X    /* wasp */
  315. X    wx[0] = BORDER + random(231) % (winW - 2*BORDER);
  316. X    wy[0] = BORDER + random(231) % (winH - 2*BORDER);
  317. X    wx[1] = wx[0];
  318. X    wy[1] = wy[0];
  319. X    wxv = 0;
  320. X    wyv = 0;
  321. X
  322. X    /* bees */
  323. X    for (b = 0 ; b < bees ; b++)
  324. X    {
  325. X        X(0,b) = random(231) % winW;
  326. X        X(1,b) = X(0,b);
  327. X        Y(0,b) = random(231) % winH;
  328. X        Y(1,b) = Y(0,b);
  329. X        xv[b] = RAND(7);
  330. X        yv[b] = RAND(7);
  331. X    }
  332. X
  333. X    /* loop until key is pressed */
  334. X    while (!kbhit())
  335. X    {
  336. X        /* <=- Wasp -=> */
  337. X        /* Age the arrays. */
  338. X        wx[2] = wx[1];
  339. X        wx[1] = wx[0];
  340. X        wy[2] = wy[1];
  341. X        wy[1] = wy[0];
  342. X        /* Accelerate */
  343. X        wxv += RAND(wasp_acc);
  344. X        wyv += RAND(wasp_acc);
  345. X
  346. X        /* Speed Limit Checks */
  347. X        if (wxv > wasp_vel) wxv = wasp_vel;
  348. X        if (wxv < -wasp_vel) wxv = -wasp_vel;
  349. X        if (wyv > wasp_vel) wyv = wasp_vel;
  350. X        if (wyv < -wasp_vel) wyv = -wasp_vel;
  351. X
  352. X        /* Move */
  353. X        wx[0] = wx[1] + wxv;
  354. X        wy[0] = wy[1] + wyv;
  355. X
  356. X        /* Bounce Checks */
  357. X        if ((wx[0] < border) || (wx[0] > winW-border-1))
  358. X        {
  359. X            wxv = -wxv;
  360. X            wx[0] += wxv;
  361. X        }
  362. X        if ((wy[0] < border) || (wy[0] > winH-border-1))
  363. X        {
  364. X            wyv = -wyv;
  365. X            wy[0] += wyv;
  366. X        }
  367. X
  368. X        /* Don't let things settle down. */
  369. X        xv[random(231) % bees] += RAND(3);
  370. X        yv[random(231) % bees] += RAND(3);
  371. X
  372. X        /* <=- Bees -=> */
  373. X        for (b = 0 ; b < bees ; b++)
  374. X        {
  375. X            /* Age the arrays. */
  376. X            X(2,b) = X(1,b);
  377. X            X(1,b) = X(0,b);
  378. X            Y(2,b) = Y(1,b);
  379. X            Y(1,b) = Y(0,b);
  380. X
  381. X            /* Accelerate */
  382. X            dx = wx[1] - X(1,b);
  383. X            dy = wy[1] - Y(1,b);
  384. X            distance = abs(dx)+abs(dy); /* approximation */
  385. X            if (distance == 0) distance = 1;
  386. X            xv[b] += (dx*bee_acc)/distance;
  387. X            yv[b] += (dy*bee_acc)/distance;
  388. X
  389. X            /* Speed Limit Checks */
  390. X            if (xv[b] > bee_vel) xv[b] = bee_vel;
  391. X            if (xv[b] < -bee_vel) xv[b] = -bee_vel;
  392. X            if (yv[b] > bee_vel) yv[b] = bee_vel;
  393. X            if (yv[b] < -bee_vel) yv[b] = -bee_vel;
  394. X
  395. X            /* Move */
  396. X            X(0,b) = X(1,b) + xv[b];
  397. X            Y(0,b) = Y(1,b) + yv[b];
  398. X
  399. X            /* Fill the segment lists. */
  400. X            segs[b].x1 = X(0,b);
  401. X            segs[b].y1 = Y(0,b);
  402. X            segs[b].x2 = X(1,b);
  403. X            segs[b].y2 = Y(1,b);
  404. X            old_segs[b].x1 = X(1,b);
  405. X            old_segs[b].y1 = Y(1,b);
  406. X            old_segs[b].x2 = X(2,b);
  407. X            old_segs[b].y2 = Y(2,b);
  408. X        }
  409. X
  410. X        /* Erase previous, draw current, sync for smoothness. */
  411. X
  412. X        /* Wasp */
  413. X        if (xor) /* xor doesn't make sense on a PC (no root window,...)
  414. X                    therfore I slightly changed the meaning of this
  415. X                    switch :-) */
  416. X        {
  417. X            if (init == FALSE)
  418. X            {
  419. X              if ((goodCoord(wx[1], wy[1])) && (goodCoord(wx[2],wy[2])))
  420. X              {
  421. X                if (!(wasp_color == 0))
  422. X                  setcolor(wasp_color);
  423. X                line(wx[1], wy[1], wx[2], wy[2]);
  424. X              }
  425. X            }
  426. X              if ((goodCoord(wx[0], wy[0])) && (goodCoord(wx[1],wy[1])))
  427. X              {
  428. X                if (!(wasp_color == 0))
  429. X                  setcolor(wasp_color);
  430. X                line(wx[0], wy[0], wx[1], wy[1]);
  431. X              }
  432. X        }
  433. X        else
  434. X        {
  435. X            if (init == FALSE)
  436. X                FGcolor=getcolor();
  437. X                BGcolor=getbkcolor();
  438. X                setcolor(BGcolor);                /*       */
  439. X              if ((goodCoord(wx[1], wy[1])) && (goodCoord(wx[2],wy[2])))
  440. X                line(wx[1], wy[1], wx[2], wy[2]); /* erase */
  441. X                setcolor(FGcolor);                /*       */
  442. X              if ((goodCoord(wx[0], wy[0])) && (goodCoord(wx[1],wy[1])))
  443. X              {
  444. X                if (!(wasp_color == 0))
  445. X                  setcolor(wasp_color);
  446. X                line(wx[0], wy[0], wx[1], wy[1]);
  447. X              }
  448. X        }
  449. X
  450. X        /* Bees */
  451. X        if (xor)
  452. X        {
  453. X            if (init == FALSE)
  454. X               {
  455. X                setcolor(BGcolor);                /*       */
  456. X                DrawSegments(old_segs, bees);     /* XOR   */
  457. X                setcolor(FGcolor);                /*       */
  458. X               }
  459. X            else
  460. X                init = FALSE;
  461. X                if (!(bee_color == 0))
  462. X                  setcolor(bee_color);
  463. X                DrawSegments(segs, bees);
  464. X        }
  465. X        else
  466. X        {
  467. X            if (init == FALSE)
  468. X            {
  469. X                setcolor(BGcolor);                /*       */
  470. X                 DrawSegments(old_segs, bees);    /* erase */
  471. X                 setcolor(FGcolor);                /*       */
  472. X            }
  473. X
  474. X            else
  475. X                init = FALSE;
  476. X            DrawSegments(segs,bees);
  477. X        }
  478. X
  479. X
  480. X        /* Clean up and shut down.
  481. X        if (stop)
  482. X        {
  483. X            if (xor)
  484. X            {
  485. X                DrawSegments(segs, bees);
  486. X                DrawLine(wx[0], wy[0], wx[1], wy[1]);
  487. X            }
  488. X            else
  489. X                XFillRectangle(display.dpy, display.win, display.erase_gc,
  490. X                    0,0, winW, winH);
  491. X            XSync(display.dpy, 0);
  492. X            exit(0);
  493. X        } */
  494. X
  495. X        /* Delay so we don't use all of the cpu time. */
  496. X        if (delay != 0) nap(delay);
  497. X    }
  498. X  return(0);
  499. X}
  500. X
  501. X
  502. X/* nap
  503. X**
  504. X** put the process to sleep for a while
  505. X*/
  506. X
  507. Xvoid nap(usec)
  508. Xint usec;
  509. X
  510. X{
  511. Xint i;
  512. X
  513. Xfor (i=1; i<usec; i++);
  514. X
  515. X}
  516. X
  517. X
  518. Xvoid Usage(program)
  519. Xchar *program;
  520. X{
  521. X
  522. X    printf("swarm [options]  where options are listed below\n", program);
  523. X    printf(" ! no space between option and value; e.g.: swarm b30\n");
  524. X    printf("d delay     delay between screen updates in millikeilholz\n");
  525. X    printf("            ( 0 <= d <= 32000 )\n");
  526. X    printf("x           do not erase bees's and wasp's trails\n");
  527. X    printf("b bees      number of bees\n");
  528. X    printf("a bee_acc   bee acceleration in pixels per frame per frame\n");
  529. X    printf("s bee_vel   bee speed limit in pixels per frame\n");
  530. X    printf("A wasp_acc  wasp max acceleration in pixels per frame per frame\n");
  531. X    printf("S wasp_vel  wasp speed limit in pixels per frame\n");
  532. X    printf("B width     border width that wasp can't cross\n");
  533. X    printf("            ( 0 <= d <= 65 )\n");
  534. X    printf("w wasp_clr  wasp color\n");
  535. X    printf("c bee_clr   bee color\n");
  536. X    printf("C bg_color  background color\n");
  537. X    printf("v           verbose\n");
  538. X    printf("h|q|?               display this message\n");
  539. X    printf("\nPress any key to stop the insanity.\n");
  540. X    exit(0);
  541. X}
  542. X
  543. X
  544. Xvoid HandleError(description, degree)
  545. Xchar    *description;
  546. Xint     degree;
  547. X{
  548. X    fprintf(stderr, "An error has occurred.  The description is below...\n");
  549. X    fprintf(stderr, "%s\n", description);
  550. X
  551. X    if (degree == FATAL)
  552. X    {
  553. X        fprintf(stderr, "Program aborting...\n");
  554. X        exit(-1);
  555. X    }
  556. X}
  557. X
  558. X
  559. Xvoid DrawSegments(XSegment *segments, int bees)
  560. X
  561. X{
  562. X  int i;
  563. X
  564. X  for (i=1; i<= bees; i++)
  565. X  {
  566. X    if ((goodCoord(segments[i].x1, segments[i].y1) ) &&
  567. X        (goodCoord(segments[i].x2, segments[i].y2) )     )
  568. X        line(segments[i].x1, segments[i].y1, segments[i].x2,segments[i].y2);
  569. X  }
  570. X
  571. X}
  572. X
  573. Xint goodCoord(int x, int y)    /* boolean */
  574. X
  575. X/* In TURBO C++ we need to check the boundaries ...
  576. X   drawing lines outside the viewport would mess
  577. X   up the display                                  */
  578. X
  579. X{
  580. Xif ( (x >0) && (x <= getmaxx()) &
  581. X     (y >0) && (y <= getmaxy())    )
  582. X   return(true);
  583. Xelse
  584. X   return(false);
  585. X
  586. X}
  587. X
  588. X
  589. END_OF_FILE
  590. if test 14177 -ne `wc -c <'swarm.c'`; then
  591.     echo shar: \"'swarm.c'\" unpacked with wrong size!
  592. fi
  593. # end of 'swarm.c'
  594. fi
  595. if test -f 'swarm.h' -a "${1}" != "-c" ; then 
  596.   echo shar: Will not clobber existing file \"'swarm.h'\"
  597. else
  598. echo shar: Extracting \"'swarm.h'\" \(2704 characters\)
  599. sed "s/^X//" >'swarm.h' <<'END_OF_FILE'
  600. X/* Constants */
  601. X#define TRUE 1
  602. X#define FALSE 0
  603. X#define STD_STR 100
  604. X#define BEES    20      /* number of bees */
  605. X#define TIMES   3       /* number of time positions recorded */
  606. X#define BEEACC  3       /* acceleration of bees */
  607. X#define WASPACC 5       /* maximum acceleration of wasp */
  608. X#define BEEVEL  11      /* maximum bee velocity */
  609. X#define WASPVEL 12      /* maximum wasp velocity */
  610. X#define DELAY   0       /* delay between updates */
  611. X#define WINWIDTH 512    /* default window width */
  612. X#define WINHEIGHT 512   /* default window height */
  613. X#define BORDER  50      /* wasp won't go closer than this to the edges */
  614. X#define NULL 0          /* not predefined ??? &&& */
  615. X
  616. X#define MaxBees 200
  617. X
  618. X/* Error Codes */
  619. X#define FATAL   -1
  620. X#define WARNING -2
  621. X
  622. X/* Macros */
  623. X#define X(t,b)  (x[t*bees + b])         /* addressing into dynamic array */
  624. X#define Y(t,b)  (y[t*bees + b])         /* addressing into dynamic array */
  625. X#define RAND(v) ((random(v) % v) - (v/2))  /*random number around 0 */
  626. X
  627. X/* Type Definitions */
  628. X
  629. Xtypedef int Window;   /* Nonsense &&& */
  630. Xtypedef int Display;  /* Nonsense &&& */
  631. Xtypedef int GC;       /* Nonsense &&& */
  632. Xtypedef int Atom;     /* Nonsense &&& */
  633. Xtypedef Colormap;     /* Nonsense &&& */
  634. X
  635. X
  636. X
  637. Xtypedef struct _disp
  638. X{
  639. X        Window  win;
  640. X        Display *dpy;
  641. X        char    *dname;
  642. X        long    wasp, bee, bg; /* colors */
  643. X        GC      wasp_gc;
  644. X        GC      bee_gc;
  645. X        GC      erase_gc;
  646. X        GC      wasp_xor_gc;
  647. X        GC      bee_xor_gc;
  648. X        Atom    kill_atom, protocol_atom;
  649. X        Colormap cmap;
  650. X} disp;
  651. X
  652. Xtypedef struct
  653. X{
  654. X  short x1;
  655. X  short x2;
  656. X  short y1;
  657. X  short y2;
  658. X} XSegment;
  659. X
  660. Xenum boolean {false, true};
  661. X
  662. X/* Function Prototypes */
  663. Xvoid    nap();
  664. Xvoid    Usage();
  665. Xvoid    HandleError();
  666. Xlong    GetColor();
  667. Xvoid    DrawSegments(XSegment *segments, int bees);
  668. Xint     goodCoord(int x, int y); /* int = boolean ? */
  669. X
  670. X/* Global Variables */
  671. X
  672. X/* X related */
  673. Xint             winX, winY;
  674. Xunsigned int    winW, winH;
  675. X
  676. X/* animation related */
  677. Xint     times = TIMES;          /* number of time steps recorded  */
  678. Xint     bees = BEES;            /* number of bees */
  679. Xint     wasp_vel = WASPVEL;     /* maximum wasp speed */
  680. Xint     bee_vel = BEEVEL;       /* maximum bee speed */
  681. Xint     wasp_acc = WASPACC;     /* maximum wasp acceleration */
  682. Xint     bee_acc = BEEACC;       /* bee acceleration */
  683. Xint     delay = DELAY;          /* delay between updates, in microseconds */
  684. Xint     border = BORDER;        /* border limiting wasp travel */
  685. Xint     wasp_color = 0;
  686. Xint     bee_color = 0;
  687. Xint     bg_color = 0;
  688. Xchar    stop = FALSE;
  689. Xint     xor = FALSE;            /* use GXxor if TRUE */
  690. Xint     verbose = FALSE;        /* display settings if TRUE */
  691. X
  692. END_OF_FILE
  693. if test 2704 -ne `wc -c <'swarm.h'`; then
  694.     echo shar: \"'swarm.h'\" unpacked with wrong size!
  695. fi
  696. # end of 'swarm.h'
  697. fi
  698. echo shar: End of archive 1 \(of 1\).
  699. cp /dev/null ark1isdone
  700. MISSING=""
  701. for I in 1 ; do
  702.     if test ! -f ark${I}isdone ; then
  703.     MISSING="${MISSING} ${I}"
  704.     fi
  705. done
  706. if test "${MISSING}" = "" ; then
  707.     echo You have the archive.
  708.     rm -f ark[1-9]isdone
  709. else
  710.     echo You still need to unpack the following archives:
  711.     echo "        " ${MISSING}
  712. fi
  713. ##  End of shell archive.
  714. exit 0
  715.